package com.hh.controller;

import com.hh.entity.SysRole;
import com.hh.service.SysRoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 辉辉 2022/8/16 9:27
 */
@Api(tags = "权限的接口")
@RestController
@RequestMapping("/sys/role")
public class SysRoleController {
    @Resource
    private SysRoleService sysRoleService;

    @GetMapping("/list")
    @ApiOperation("查询所有角色")
    @PreAuthorize("hasAuthority('sys:role:page')")
    public ResponseEntity<List<SysRole>> loadAllRole() {
        List<SysRole> list = sysRoleService.list();
        System.err.println(list);
        return ResponseEntity.ok(list);
    }
}
